home *** CD-ROM | disk | FTP | other *** search
- /****************
- * MenuMaze.c
- *
- * Copyright © 1994 Fresh Software and Instructional Design, All Rights Reserved.
- *
- * 6/23/94 wdh created
- ********************************************************************************/
-
-
- #define FailNIL(h) if ((h) == NULL) goto error
- #define FailOSErr(err) if ((err) != noErr) goto error
-
- #define abs(x) ((x) < 0 ? -(x) : (x))
-
- #define kMenuBAR 128
- #define kSplashDLOG 2048
-
- void main(void)
- {
- short type; Handle h; Rect r;
- EventRecord event;
- Handle mbar;
- DialogPtr dp;
- long result;
- long totalCount = 0;
- Boolean done;
- MenuHandle mh;
- int i;
- short realQuitItem, realQuitMenu;
- short totalMenus;
-
- MaxApplZone(); /* grow the application heap to its maximum possible size */
- MoreMasters(); /* Create 64 more master pointers */
- MoreMasters(); /* Create 64 more master pointers */
- MoreMasters(); /* Create 64 more master pointers */
- MoreMasters(); /* Create 64 more master pointers */
-
- InitGraf(&qd.thePort); /* init Quickdraw and global variables */
- InitFonts(); /* initialize font manager */
- InitWindows(); /* init window manager and setup WMgr GrafPort */
- InitMenus(); /* initialize menu Manager */
- TEInit(); /* inititalize TextEdit */
- InitDialogs(0); /* initialize Dialog manager */
- FlushEvents(everyEvent, 0); /* clear the Event queue of all events */
- InitCursor(); /* set the cursor to arrow instead of clock */
-
- mbar = GetNewMBar(kMenuBAR);
- SetMenuBar(mbar);
- DrawMenuBar();
- {
- MenuHandle mh = GetMHandle(512);
- AddResMenu(mh, 'DRVR');
- }
- for (i = 128; i < 140; i++)
- {
- mh = GetMenu(i);
- if (mh == NULL)
- break;
- InsertMenu(mh, -1);
- }
-
- /****************
- * Set real quit
- ********************************************************************************/
- totalMenus = (i > 5) ? 5 : i;
- i = Random()%(totalMenus);
- i = abs(i);
- mh = GetMHandle(i+128);
- realQuitMenu = i;
- i = (Random()%7) + 1;
- i = abs(i);
- realQuitItem = i;
- SetItem(mh, i, "\pQuit");
- SetItemCmd(mh, i, noMark);
- SetItemMark(mh, i, noMark);
-
- /****************
- * Set a coupla false quits
- ********************************************************************************/
- do {
- i = Random()%(totalMenus);
- i = abs(i);
- mh = GetMHandle(i+128);
- } while (i == realQuitMenu);
- do {
- i = (Random()%7) + 1;
- i = abs(i) + 1;
- } while (i == realQuitItem);
- SetItem(mh, i, "\pQuit");
- SetItemCmd(mh, i, noMark);
- SetItemMark(mh, i, noMark);
- DisableItem(mh, i);
-
- do {
- i = Random()%(totalMenus);
- i = abs(i);
- mh = GetMHandle(i+128);
- } while (i == realQuitMenu);
- do {
- i = (Random()%7);
- i = abs(i) + 1;
- } while (i == realQuitItem);
- SetItem(mh, i, "\pQuit");
- SetItemCmd(mh, i, noMark);
- SetItemMark(mh, i, noMark);
- DisableItem(mh, i);
-
- dp = GetNewDialog(kSplashDLOG, NULL, (WindowPtr)-1);
- ShowWindow(dp);
-
- done = false;
- do {
- WindowPtr wp;
- WaitNextEvent(everyEvent, &event, 60, NULL);
- switch (event.what)
- {
- case keyDown:
- done = true;
- break;
- case updateEvt:
- BeginUpdate((WindowPtr)event.message);
- DrawDialog(dp);
- EndUpdate((WindowPtr)event.message);
- break;
- case mouseDown:
- if ((i = FindWindow(event.where, &wp)) == inMenuBar)
- {
- Str63 itemName;
- result = MenuSelect(event.where);
- if (HiWord(result))
- {
- GetItem(GetMHandle(HiWord(result)), LoWord(result), itemName);
- done = !IUEqualString("\pQuit", itemName);
- }
- HiliteMenu(0);
- }
- else if (i == inContent)
- {
- GetDialogItem(dp, 3, &type, &h, &r);
- SetIText(h, "\pYou are in a maze of twisty passages, all alike...");
- }
- break;
- case nullEvent:
- break;
- default:
- break;
- }
- } while (!done);
- error:
- return;
- } /* main */
-
-